var netcore = require('../../../utils/network.js')
var wxCrypt = require('../../../utils/WXBizDataCrypt.js')
var tripleDes = require('../../../utils/CKCrypto.js')

function getUserInfo(callBack){
  var map=new Map();
  netcore.requestPost("account/getUserInfo.do", map, function (success) {
    success.userName = tripleDes.deCode(success.userName+"")
    success.phone = tripleDes.deCode(success.phone+"")
    success.userIcon = tripleDes.deCode(success.userIcon+"")
    success.userState = tripleDes.deCode(success.userState+"")
    success.userBirthDate = tripleDes.deCode(success.userBirthDate+"")
    success.vipLevel = tripleDes.deCode(success.vipLevel+"")
    success.provinceText = tripleDes.deCode(success.provinceText+"")
    success.cityText = tripleDes.deCode(success.cityText+"")
    success.regionText = tripleDes.deCode(success.regionText+"")
    callBack(success)
  }, function (errorCode, errMsg) {
    wx.showToast({
      title: errMsg,
      icon: 'none',
    })
  })
}
function saveUserInfo(user,callBack){
  var map = new Map();
  map.set("iconBit", user.iconBit)
  map.set("userName", tripleDes.enCode(user.userName+""))
  map.set("userSex", tripleDes.enCode(user.userSex+""))
  map.set("birthDate", tripleDes.enCode(user.birthDate+""))
  map.set("des", tripleDes.enCode(user.des+""))
  map.set("gradeLevel", tripleDes.enCode(user.gradeLevel+""))
  netcore.requestPost("account/updateUserInfo.do", map, function (success) {
    callBack(success)
  }, function (errorCode, errMsg) {
    wx.showToast({
      title: errMsg,
      icon: 'none',
    })
  })
}
function accountExit(callBack){
  var map = new Map();
  netcore.requestPost("account/accountExit.do", map, function (success) {
    callBack(success)
  }, function (errorCode, errMsg) {
    wx.showToast({
      title: errMsg,
      icon: 'none',
    })
  })
}
module.exports = {
  getUserInfo: getUserInfo,
  saveUserInfo: saveUserInfo,
  accountExit: accountExit
}